rgba: Invert the arguments and improve bindability
authorEmmanuele Bassi <ebassi@linux.intel.com>
Sun, 28 Nov 2010 18:49:47 +0000 (18:49 +0000)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Sun, 28 Nov 2010 19:01:51 +0000 (19:01 +0000)
Since parse() is a method of the Gdk.RGBA class, the GdkRGBA pointer
should be the first argument, and the string the second one, to allow a
more natural binding.

https://bugzilla.gnome.org/show_bug.cgi?id=635879

gdk/gdkrgba.c
gdk/gdkrgba.h
gdk/tests/gdk-color.c
gtk/gtkbuilder.c
gtk/gtkcellrenderer.c
gtk/gtkcellrenderertext.c

index 732cf99190ea0b15ebc123ea9c336dddac9f6490..c2cf2fca3167fe8215e31fc62bdff79fa8bd8eec 100644 (file)
@@ -115,8 +115,8 @@ parse_rgb_value (const char  *str,
 
 /**
  * gdk_rgba_parse:
- * @spec: the string specifying the color
  * @rgba: the #GdkRGBA struct to fill in
+ * @spec: the string specifying the color
  *
  * Parses a textual representation of a color, filling in
  * the <structfield>red</structfield>, <structfield>green</structfield>,
@@ -150,8 +150,8 @@ parse_rgb_value (const char  *str,
  * Since: 3.0
  **/
 gboolean
-gdk_rgba_parse (const gchar *spec,
-                GdkRGBA     *rgba)
+gdk_rgba_parse (GdkRGBA     *rgba,
+                const gchar *spec)
 {
   gboolean has_alpha;
   gdouble r, g, b, a;
index 9875d105c5d850e931ada507ee827ee49f2af46f..2b7670477ac5d015327235c52a9e77a5ee00dffe 100644 (file)
@@ -48,8 +48,8 @@ struct _GdkRGBA
 GdkRGBA * gdk_rgba_copy (GdkRGBA *rgba);
 void      gdk_rgba_free (GdkRGBA *rgba);
 
-gboolean  gdk_rgba_parse (const gchar *spec,
-                          GdkRGBA     *rgba);
+gboolean  gdk_rgba_parse (GdkRGBA     *rgba,
+                          const gchar *spec);
 
 guint     gdk_rgba_hash  (gconstpointer p);
 gboolean  gdk_rgba_equal (gconstpointer p1,
index 2dbe2ad24891c59ab114a6ca689f18bbba4ac37d..008f425e2856fa87cb19c09bae1ee34e85efb62f 100644 (file)
@@ -8,17 +8,17 @@ test_color_parse (void)
   GdkRGBA expected;
   gboolean res;
 
-  res = gdk_rgba_parse ("foo", &color);
+  res = gdk_rgba_parse (&color, "foo");
   g_assert (!res);
 
-  res = gdk_rgba_parse ("", &color);
+  res = gdk_rgba_parse (&color, "");
   g_assert (!res);
 
   expected.red = 100/255.;
   expected.green = 90/255.;
   expected.blue = 80/255.;
   expected.alpha = 0.1;
-  res = gdk_rgba_parse ("rgba(100,90,80,0.1)", &color);
+  res = gdk_rgba_parse (&color, "rgba(100,90,80,0.1)");
   g_assert (res);
   g_assert (gdk_rgba_equal (&color, &expected));
 
@@ -26,11 +26,11 @@ test_color_parse (void)
   expected.green = 0.3;
   expected.blue = 0.2;
   expected.alpha = 0.1;
-  res = gdk_rgba_parse ("rgba(40%,30%,20%,0.1)", &color);
+  res = gdk_rgba_parse (&color, "rgba(40%,30%,20%,0.1)");
   g_assert (res);
   g_assert (gdk_rgba_equal (&color, &expected));
 
-  res = gdk_rgba_parse ("rgba(  40 % ,  30 %  ,   20 % ,  0.1    )", &color);
+  res = gdk_rgba_parse (&color, "rgba(  40 % ,  30 %  ,   20 % ,  0.1    )");
   g_assert (res);
   g_assert (gdk_rgba_equal (&color, &expected));
 
@@ -38,7 +38,7 @@ test_color_parse (void)
   expected.green = 0.0;
   expected.blue = 0.0;
   expected.alpha = 1.0;
-  res = gdk_rgba_parse ("red", &color);
+  res = gdk_rgba_parse (&color, "red");
   g_assert (res);
   g_assert (gdk_rgba_equal (&color, &expected));
 
@@ -46,7 +46,7 @@ test_color_parse (void)
   expected.green = 0x8080 / 65535.;
   expected.blue = 1.0;
   expected.alpha = 1.0;
-  res = gdk_rgba_parse ("#0080ff", &color);
+  res = gdk_rgba_parse (&color, "#0080ff");
   g_assert (res);
   g_assert (gdk_rgba_equal (&color, &expected));
 }
@@ -71,7 +71,7 @@ test_color_to_string (void)
 
   orig = g_strdup (setlocale (LC_ALL, NULL));
   res = gdk_rgba_to_string (&rgba);
-  gdk_rgba_parse (res, &out);
+  gdk_rgba_parse (&out, res);
   g_assert (gdk_rgba_equal (&rgba, &out));
 
   setlocale (LC_ALL, "de_DE.utf-8");
index 7ed026c0a7350b43fd6be207ab6641697f462c8b..97b0053da3c3f127561d8fa67ac24202a00f4972 100644 (file)
@@ -1563,7 +1563,7 @@ gtk_builder_value_from_string_type (GtkBuilder   *builder,
         {
           GdkRGBA rgba = { 0 };
 
-          if (gdk_rgba_parse (string, &rgba))
+          if (gdk_rgba_parse (&rgba, string))
             g_value_set_boxed (value, &rgba);
           else
             {
index fe8a67b482a41863ecb849627edd06786d68809c..e05ec4ccc3484b6b1e91200a3a04442ad670cea8 100644 (file)
@@ -534,7 +534,7 @@ gtk_cell_renderer_set_property (GObject      *object,
 
         if (!g_value_get_string (value))
           set_cell_bg_color (cell, NULL);
-        else if (gdk_rgba_parse (g_value_get_string (value), &rgba))
+        else if (gdk_rgba_parse (&rgba, g_value_get_string (value)))
           set_cell_bg_color (cell, &rgba);
         else
           g_warning ("Don't know color `%s'", g_value_get_string (value));
index a93f16c9dcb3c7f49a600e01b042b6ab882b9935..cf58d4dacbde0b7a1514bced623a750948312f4e 100644 (file)
@@ -1193,7 +1193,7 @@ gtk_cell_renderer_text_set_property (GObject      *object,
 
         if (!g_value_get_string (value))
           set_bg_color (celltext, NULL);       /* reset to background_set to FALSE */
-        else if (gdk_rgba_parse (g_value_get_string (value), &rgba))
+        else if (gdk_rgba_parse (&rgba, g_value_get_string (value)))
           set_bg_color (celltext, &rgba);
         else
           g_warning ("Don't know color `%s'", g_value_get_string (value));
@@ -1208,7 +1208,7 @@ gtk_cell_renderer_text_set_property (GObject      *object,
 
         if (!g_value_get_string (value))
           set_fg_color (celltext, NULL);       /* reset to foreground_set to FALSE */
-        else if (gdk_rgba_parse (g_value_get_string (value), &rgba))
+        else if (gdk_rgba_parse (&rgba, g_value_get_string (value)))
           set_fg_color (celltext, &rgba);
         else
           g_warning ("Don't know color `%s'", g_value_get_string (value));